import Taro, { Component } from '@tarojs/taro'
import { View, Text } from '@tarojs/components'

class PlayList extends Component {
  static defaultProps = {
    playList: []
  }

  onOpen = pid => {
    const id = this.props.id
    Taro.navigateTo({
      url: `/pages/play/index?id=${id}&pid=${pid}`
    })
  }

  render() {
    const { playList = [] } = this.props
    return (
      <View>
        {playList.map(item => (
          <View onClick={this.onOpen.bind(this, item.episode)} key={item.episode}>
            <Text>{item.title}</Text>
          </View>
        ))}
      </View>
    )
  }
}

export default PlayList
